package com.site.wisdom_construction.controller.iotModule;

import com.site.wisdom_construction.responseEntity.JsonResult;
import com.site.wisdom_construction.responseEntity.Page;
import com.site.wisdom_construction.service.iotModule.PersonnelTagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author daiyifei
 * @Date 2022/3/10
 * @Description
 */
@Api(tags = "人员定位安全帽信息接口")
@RestController
@RequestMapping("PersonnelTag")
@CrossOrigin
public class PersonnelTagController {
    @Autowired
    private PersonnelTagService personnelTagService;

    @ApiOperation(value = "修改人员定位安全帽信息",notes = "")
    @PostMapping("/updatePersonnelTag")
    public JsonResult updatePersonnelTag(@RequestBody Map map){
        JsonResult jsonResult = new JsonResult();
        int i = personnelTagService.updatePersonnelTag(map);
        if (i==1){
            jsonResult.setCode(200);
            jsonResult.setMessage("修改成功!");
        }else {
            jsonResult.setCode(20006);
            jsonResult.setMessage("修改失败!");
        }
        return jsonResult;
    }

    @ApiOperation(value = "分页模糊查询安全帽信息",notes = "")
    @PostMapping("/findPersonnelTagByPage")
    public Page findPersonnelTagByPage(@RequestBody Map map){
        Page page = new Page();
        page.setPageNo((Integer) map.get("pageNo"));
        page.setPageSize((Integer) map.get("pageSize"));
        page.setTotal(personnelTagService.Total(map));
        page.setItems(personnelTagService.findPersonnelTagByPage(map));
        return page;
    }
}
